package net.geektao.lab.spring.beansoftype;

import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.InitializingBean;

/**
 * 业务分发器工厂Bean。
 * 
 * @author geektao
 *
 */
public class BusinessDispatcherFactoryBean implements FactoryBean<BusinessDispatcher>, InitializingBean {

	private BusinessDispatcher businessDispatcher = null;

	private BusinessProcessorsManager businessProcessorsManager;

	public BusinessProcessorsManager getBusinessProcessorsManager() {
		return businessProcessorsManager;
	}

	public void setBusinessProcessorsManager(BusinessProcessorsManager businessProcessorsManager) {
		this.businessProcessorsManager = businessProcessorsManager;
	}

	@Override
	public BusinessDispatcher getObject() throws Exception {
		return businessDispatcher;
	}

	@Override
	public Class<?> getObjectType() {
		return BusinessDispatcher.class;
	}

	@Override
	public boolean isSingleton() {
		return true;
	}

	@Override
	public void afterPropertiesSet() throws Exception {
		
		businessDispatcher = new BusinessDispatcher();
		businessDispatcher.setBusinessProcessorsManager(getBusinessProcessorsManager());
	}

}
